﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Xml.Linq;
using Ninject;
using Ninject.Syntax;
using Orange.Logistics.Services;
using System.Reflection;

namespace Orange.Logistics.Infrastructure {
    public class NinjectDependencyResolver : IDependencyResolver {
        private IKernel kernel;

        public NinjectDependencyResolver() {
            kernel = new StandardKernel();
            AddBindings();
        }

        public IKernel Kernel { get { return kernel; } }

        public object GetService(Type serviceType) {
            return kernel.TryGet(serviceType);
        }

        public IEnumerable<object> GetServices(Type serviceType) {
            return kernel.GetAll(serviceType);
        }

        public IBindingToSyntax<T> Bind<T>() {
            return kernel.Bind<T>();
        }

        private void AddBindings() {
            //Bind<IViewEngine>().To<OrangeViewEngine>();
            Bind<ISystemService>().To<SystemService>();
            Bind<IPermissionService>().To<PermissionService>();
            Bind<IModuleService>().To<ModuleService>();
            Bind<ICustomerService>().To<CustomerService>();
            Bind<IGroupService>().To<GroupService>();
            //Bind<ICustomerGroupService>().To<CustomerGroupService>();
            Bind<IStockService>().To<StockService>();
            Bind<IStockDetailService>().To<StockDetailService>();
            Bind<IMemorycardService>().To<MemorycardService>();
            Bind<IStoreService>().To<StoreService>();
            Bind<IJobService>().To<JobService>();
            Bind<IBillService>().To<BillService>();
            Bind<IVenueService>().To<VenueStaffService>();           
        }
    }
}